<?php

namespace App\ModelFilters;


class CzProductFilter extends BaseFilter
{
    /**
     * Related Models that have ModelFilters as well as the method on the ModelFilter
     * As [relationMethod => [input_key1, input_key2]].
     *
     * @var array
     */
    public $relations = [];

    public function id($value)
    {
        return $this->where('id', $value);
    }

    public function title($value)
    {
        return $this->where('title', 'LIKE', "%$value%");
    }
    public function type($value)
    {
        return $this->where('type', $value);
    }
    public function isp($value)
    {
        return $this->where('isp', $value);
    }
    public function status($value)
    {
        return $this->where('status', $value);
    }
    public function province_id($value)
    {
        return $this->where('province_id', $value);
    }
    public function city_id($value)
    {
        return $this->where('city_id', $value);
    }
    public function hf_type($value)
    {
        return $this->where('hf_type', $value);
    }

    public function mobi_province_id($value)
    {
        return $this->where(function ($query) use ($value) {
            $query->Orwhere('province_id', $value)
                ->Orwhere('province_id', 0);
        });
    }
    public function mobi_city_id($value)
    {
        return $this->where(function ($query) use ($value) {
            $query->Orwhere('city_id', $value)
                ->Orwhere('city_id', 0);
        });
    }

    public function mobi_spec_id($value)
    {
        return $this->related('specs', function ($query) use ($value) {
            return $query->whereIn('id', $value);
        });
    }
}
